var express = require('express');
var router = express.Router();

var articles = require('./article.json');
router.get('/article/:id' ,function(req, res){
  const id = req.params.id ;
  res.locals.user = req.session.user || "";
  const article = articles[id];
  res.locals.article = article;
  res.render('article_content');
});

router.get('/', function(req, res){
  res.locals.user = req.session.user || "";
  res.locals.articles = articles;
  res.render('article');
});
module.exports = router;
